package com.abel.bigwater.wflow

import com.abel.bigmeter.service.MeterParam
import com.abel.bigwater.model.BwUser
import com.abel.bigwater.model.zone.ZoneMeter
import com.abel.bigwater.wflow.mapper.DataMapper
import com.abel.bigwater.wflow.mapper.MeterMapper
import com.abel.bigwater.wflow.mapper.ZoneMapper
import org.springframework.stereotype.Controller
import org.springframework.ui.Model
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestMapping

import javax.annotation.Resource

@Controller
@RequestMapping("/Meter")
class MeterController {

    @Resource
    private val meterMapper: MeterMapper? = null

    @Resource
    private val dataMapper: DataMapper? = null

    @Resource
    private val zoneMapper: ZoneMapper? = null

    //跳转详情
    @GetMapping("/list")
    fun meterList(m: Model): String {
        val me = DemoApplicationConfiguration.myself()
        val mp = MeterParam()
        mp.firmId = me!!.firmId + "%"
        val mlist = meterMapper!!.selectMeter(mp)
        m.addAttribute("meterList", mlist)
        return "meter-list"
    }

    //档案
    @GetMapping("/file/{meterId}")
    fun files(m: Model, @PathVariable("meterId") meterId: String): String {
        val mp = MeterParam()
        mp.meterId = meterId
        val mlist = meterMapper!!.selectMeter(mp)
        m.addAttribute("meter", mlist.firstOrNull())
        return "meter-file-detail"
    }

}
